package com.qdlc.p2p.biz.tpp.model;

import java.io.IOException;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.qdlc.p2p.common.constant.SinaConstant;
import com.qdlc.p2p.common.util.DateUtil;
import com.qdlc.p2p.common.util.OrderNoUtil;

/**
 * 新浪 - 绑定银行卡
 *
 * @author gcx
 * @version 2.0
 * @date 2015年8月10日 16:40
 */
public class SinaBindBankCard extends SinaModel{

	/**
	 * 绑卡请求号	   商户网站交易订单号，商户内部保证唯一
	 */
	private String request_no;

	/**
	 * 银行编号	
	 */
	private String bank_code;	

	/**
	 * 银行卡号	 密文
	 */
	private String bank_account_no;

	/**
	 * 户名		 密文， 空则使用实名认证时实名信息	
	 */
	private String account_name;

	/**
	 * 	卡类型	借记卡: DEBIT  贷记（信用卡）:CREDIT
	 */
	private String card_type;

	/**
	 * 
	 * 	卡属性	卡属性 - 对私 :C ,卡属性 - 对公 :B  
	 */
	private String  card_attribute;

	/**
	 * 证件类型  	身份证 :IC 目前只支持身份证，为空则使用实名认证中的证件信息
	 */
	private String cert_type;

	/**
	 * 证件号码	密文 ,空则使用实名认证时实名信息
	 */
	private String cert_no;	

	/**
	 * 银行预留手机号		密文, 如认证方式不为空，则要求此信息也不能为空。
	 */
	private String phone_no	;

	/**
	 * 	CVV2	 密文，使用新浪支付RSA公钥加密。明文长度：10；信用卡专用
	 */
	private String verification_value;

	/**
	 * 省份	省份 
	 */
	private String province;

	/**
	 * 城市	 城市
	 */
	private String city;

	/**
	 * 支行名称	 银行支行名称 可为空
	 */
	private String bank_branch;

	/**
	 * 认证方式	 银行卡真实性认证方式，见附录“卡认证方式”，空则表示不认证
	 */
	private String verify_mode;	

	/**
	 * 扩展信息        业务扩展信息,参数格式：参数名1^参数值1|参数名2^参数值2|……
	 */
	private String extend_param;

	
	/******** 响应信息 start ********/

	/**
	 * 卡ID      钱包系统卡ID
	 */
	private String card_id;

	/**
	 * 是否已认证 , 银行卡是否已认证，Y：已认证；N：未认证
	 */
	private String is_verified;

	/**
	 * 后续推进需要的参数,如果需要推进则会返回此参数，支付推进时需要带上此参数，ticket有效期为15分钟，只能使用一次
	 */
	private String ticket;

	/******** 响应信息 end ********/
	
	/**
	 * 待签名字符数组
	 */
	private String[] signParamNames=new String[]{"version","service","request_time","partner_id","_input_charset","request_no",
			"identity_id","identity_type","bank_code","bank_account_no","card_type","card_attribute","province","city"};

	/**
	 * 提交字符数组
	 */
	private String[] subParamNames=new String[]{"version","service","request_time","partner_id","_input_charset","request_no",
			"identity_id","identity_type","bank_code","bank_account_no","card_type","card_attribute","province","city","sign","sign_type"};

	public SinaBindBankCard() {
		super();
	}

	public SinaBindBankCard(String bank_code, String bank_account_no, String account_name,String card_type,String card_attribute,
			String cert_type,String cert_no, String phone_no, String verification_value,String province, String city,
			String bank_branch,String verify_mode, String extend_param,String identity_id) {
		super();
		this.setRequest_time(DateUtil.dateStr3(DateUtil.getNow()));
		this.setIdentity_id(identity_id);
		this.setIdentity_type(SinaConstant.IDENTITY_TYPE_UID);
		this.setRequest_no(OrderNoUtil.getInstance().getSerialNumber());
		this.bank_code = bank_code;
		this.bank_account_no = bank_account_no;
		this.account_name = account_name;
		this.setCard_type(SinaConstant.BANK_TYPE_DEBIT); 
		this.card_attribute = card_attribute;
		this.cert_type = cert_type;
		this.cert_no = cert_no;
		this.phone_no = phone_no;
		this.verification_value = verification_value;
		this.province = province;
		this.city = city;
		this.bank_branch = bank_branch;
		this.verify_mode = verify_mode;
		this.extend_param = extend_param;
		this.setService("binding_bank_card");
		this.setEncode(SinaConstant.ENCODE_TRUE);
	}
	
	@Override
	public SinaModel response(String res) throws IOException {
		try {
			JSONObject json = JSON.parseObject(res);
			card_id = json.getString("card_id");
			is_verified = json.getString("is_verified");
			if(is_verified.equals(SinaConstant.SINA_YES)){
				ticket = json.getString("ticket");
			}			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	
	public String getRequest_no() {
		return request_no;
	}
	public void setRequest_no(String request_no) {
		this.request_no = request_no;
	}
	public String getBank_code() {
		return bank_code;
	}
	public void setBank_code(String bank_code) {
		this.bank_code = bank_code;
	}
	public String getBank_account_no() {
		return bank_account_no;
	}
	public void setBank_account_no(String bank_account_no) {
		this.bank_account_no = bank_account_no;
	}
	public String getAccount_name() {
		return account_name;
	}
	public void setAccount_name(String account_name) {
		this.account_name = account_name;
	}
	public String getCard_type() {
		return card_type;
	}
	public void setCard_type(String card_type) {
		this.card_type = card_type;
	}
	public String getCard_attribute() {
		return card_attribute;
	}
	public void setCard_attribute(String card_attribute) {
		this.card_attribute = card_attribute;
	}
	public String getCert_type() {
		return cert_type;
	}
	public void setCert_type(String cert_type) {
		this.cert_type = cert_type;
	}
	public String getCert_no() {
		return cert_no;
	}
	public void setCert_no(String cert_no) {
		this.cert_no = cert_no;
	}
	public String getPhone_no() {
		return phone_no;
	}
	public void setPhone_no(String phone_no) {
		this.phone_no = phone_no;
	}
	public String getVerification_value() {
		return verification_value;
	}
	public void setVerification_value(String verification_value) {
		this.verification_value = verification_value;
	}
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getBank_branch() {
		return bank_branch;
	}
	public void setBank_branch(String bank_branch) {
		this.bank_branch = bank_branch;
	}
	public String getVerify_mode() {
		return verify_mode;
	}
	public void setVerify_mode(String verify_mode) {
		this.verify_mode = verify_mode;
	}
	public String getExtend_param() {
		return extend_param;
	}
	public void setExtend_param(String extend_param) {
		this.extend_param = extend_param;
	}
	public String[] getSignParamNames() {
		return signParamNames;
	}
	public void setSignParamNames(String[] signParamNames) {
		this.signParamNames = signParamNames;
	}
	public String[] getSubParamNames() {
		return subParamNames;
	}
	public void setSubParamNames(String[] subParamNames) {
		this.subParamNames = subParamNames;
	}
	
	
	
	

	public String getCard_id() {
		return card_id;
	}
	public void setCard_id(String card_id) {
		this.card_id = card_id;
	}
	public String getIs_verified() {
		return is_verified;
	}
	public void setIs_verified(String is_verified) {
		this.is_verified = is_verified;
	}
	public String getTicket() {
		return ticket;
	}
	public void setTicket(String ticket) {
		this.ticket = ticket;
	}


	












}
